package com.shell.governor.modules.controller;

import com.shell.bee.base.annotation.Logging;
import com.shell.bee.entity.mvc.RetMsg;
import com.shell.bee.mvc.controller.BaseController;
import com.shell.governor.modules.po.PubDate;
import com.shell.governor.modules.service.PubDateService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PubDateController extends BaseController {
	@Autowired
	private PubDateService dateService;

	@RequestMapping
	@Logging(module = "����������", methods = "������������������������")
	public List<PubDate> queryHoliday(String startDate, String endDate) throws Exception {
		List<PubDate> holidays = this.dateService.queryHoliday(startDate, endDate);
		return holidays;
	}

	@RequestMapping
	@Logging(module = "����������", methods = "������������������������")
	public RetMsg setHolidayStatus(PubDate date) throws Exception {
		RetMsg retMsg = this.dateService.setDateHolidayYesOrNo(date);
		return retMsg;
	}

	@RequestMapping
	@Logging(module = "����������", methods = "������������������������")
	public RetMsg cancelHoliday(PubDate date) throws Exception {
		RetMsg retMsg = this.dateService.cancelHoliday(date);
		return retMsg;
	}

	@RequestMapping
	@Logging(module = "����������", methods = "��������������������")
	public RetMsg isHoliday(String date) throws Exception {
		if (this.dateService.isHoliday(date.replace("-", ""))) {
			return initRetMsg("success", false, "��������������");
		}
		return initRetMsg("error", false, "����������������");
	}
}
